package com.sdry.web.controller.workplace;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sdry.model.lz.DeviceModel;
import com.sdry.model.workplace.Assemble;
import com.sdry.model.workplace.AssembleExample;
import com.sdry.model.workplace.MousseBundleSample;
import com.sdry.model.workplace.MousseSample;
import com.sdry.model.workplace.MousseSampleExample;
import com.sdry.model.workplace.MousseSampleExample.Criteria;
import com.sdry.service.workplace.AssembleServise;
import com.sdry.service.workplace.CentrifugalServise;
import com.sdry.service.workplace.MousseBundleSampleServise;
import com.sdry.service.workplace.MousseSampleServise;
import com.sdry.service.workplace.OthersService;
import com.sdry.utils.ResponseUtil;

/**
 * @ClassName: OthersController
 * @Description: 生产工位相关
 * @author tdd
 * @date 2018年8月29日
 * @version V1.0
 */
@Controller
@RequestMapping("/revoke")
public class MousseSampleRevokeController {
	//膜丝
	@Resource
    private MousseBundleSampleServise mousseBundleSampleServise;
	//膜丝绑定
	@Resource
	private MousseSampleServise mousseSampleServise;

	/**
	  * 膜丝绑定
	  * @param response
	  * @param mousseBundleSample
	  * @throws Exception
	  */
   @RequestMapping("/mousseSample")
   public void mousseSample(HttpServletResponse response,MousseSample mousseSample) throws Exception {
   	//返回标识   0 失败   -1 已经在下一工位  -2已经删除   1成功  
       int affact = 0;
       MousseSample mousseSamples = mousseSampleServise.selectByPrimaryKey(mousseSample.getMsid());
       if(mousseSamples != null){
    	   //抽检状态    0未抽检   1抽检
    	   if("0".equals(mousseSamples.getMsremark())){
    		   
    		   int aff = mousseSampleServise.deleteByPrimaryKeys(String.valueOf(mousseSample.getMsid()));
    		   if(aff > 0 ){
    			   MousseBundleSample mousseBundleSample = new MousseBundleSample();
    			   mousseBundleSample.setMbsid(Long.valueOf(mousseSample.getMbcode()));
    			   mousseBundleSample.setMbsremark("");
    			   mousseBundleSampleServise.updateByPrimaryKeySelective(mousseBundleSample);
    			   affact = 1;
    		   }
    	   }else{
    		   affact = -1;
    	   }
            
       }else{
       		affact = -2;
       }
       ResponseUtil.write(response, affact);
   }

}
